<?php

namespace Ladenise\EveBundle\Controller;


use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Ladenise\EveBundle\Entity\Invtypes;

use Doctrine\ORM\Tools\Pagination\Paginator;

/**
 * Invtypes controller.
 *
 */
class InvtypesController extends Controller
{

    /**
     * Lists all Invtypes entities.
     *
     */
    public function indexAction()
    {
        $entityManager = $this->getDoctrine()->getManager();

        $dql = "SELECT t, g FROM LadeniseEveBundle:Invtypes t LEFT JOIN t.invgroup g WHERE t.marketgroupid IS NOT NULL";
        
        $query = $entityManager->createQuery($dql)
                ->setFirstResult(0)
                ->setMaxResults(100);

        $entities = new Paginator($query);

        return $this->render('LadeniseEveBundle:Invtypes:index.html.twig', array(
                    'entities' => $entities,
        ));
    }

    /**
     * Finds and displays a Invtypes entity.
     *
     */
    public function showAction($id)
    {
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('LadeniseEveBundle:Invtypes')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find Invtypes entity.');
        }

        return $this->render('LadeniseEveBundle:Invtypes:show.html.twig', array(
            'entity'      => $entity,
        ));
    }
}
